<?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */

class opActivateBehavior extends Doctrine_Template {
	protected $_options = array ('name' => 'is_active', 'default' => 1 );
	
	protected static $enabled = true;
	
	public function setTableDefinition() {
		$this->hasColumn ( $this->_options ['name'], 'boolean', 1, array (
			'default' => $this->_options ['default'],
			'notnull' => true
		));
		
		$this->index('is_active_IDX', array('fields'=>array($this->_options['name'])));
		
		$this->addListener ( new opActivateListener () );
		Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
	}
	
	public static function enable() {
		self::$enabled = true;
	}
	
	public static function disable() {
		self::$enabled = false;
	}
	
	public static function getEnabled() {
		return self::$enabled;
	}
}
